package com.example.demo02.listener;

import com.example.demo02.entity.Students;
import com.example.demo02.service.StudentsService;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;

@RabbitListener(queues = "add")
@Component
@Slf4j
public class AddListener {
    @Autowired
    private StudentsService studentsService;


    @RabbitHandler
    public void execute(Students stu)  {
        studentsService.save(stu);
    }
}
